package org.zht.dormpro.pub.util;

import org.springframework.web.context.request.WebRequest;

import javax.servlet.http.HttpServletRequest;

public class WebUtil {
    public static boolean isAjax(HttpServletRequest request) {
        return (request.getHeader("X-Requested-With") != null
                && "XMLHttpRequest".equals(request.getHeader("X-Requested-With").toString()));
    }

    public static StringBuffer getPath(HttpServletRequest request) {
        StringBuffer realPath = new StringBuffer();
        realPath.append(request.getScheme())
                .append("://")
                .append(request.getServerName())
                .append(":")
                .append(request.getServerPort())
                .append(request.getContextPath())
                .append("/");
        return realPath;
    }
}
